NAME=dynamic-dns-tools
VERSION=$(shell cat VERSION)
REPOSITORY=registry.cn-hangzhou.aliyuncs.com/mickeyzzc

.PHONY: all build 

all: build docker

build: folder x86 arm64

clean:
	rm -rf ./packet/

folder:
	@mkdir -p ./packet/${VERSION}/

x86:
	GOOS=linux GOARCH=amd64 go build -ldflags -v -o ./packet/amd64/${VERSION}/${NAME} ./
	tar -zcvf ./packet/${VERSION}/${NAME}-${VERSION}.linux-amd64.tar.gz ./packet/amd64/${VERSION}/${NAME}

arm64:
	GOOS=linux GOARCH=arm64 go build -ldflags -v -o ./packet/arm64/${VERSION}/${NAME} ./
	tar -zcvf ./packet/${VERSION}/${NAME}-${VERSION}.linux-arm64.tar.gz ./packet/arm64/${VERSION}/${NAME}

docker:
	@docker buildx build --platform linux/amd64 --load . -t ${REPOSITORY}/${NAME}:${VERSION} --push
	@docker rmi -f ${REPOSITORY}/${NAME}:${VERSION}

docker-arm64:
	@docker buildx build --platform linux/arm64 --load . -t ${REPOSITORY}/${NAME}:arm64.${VERSION} --push
	@docker rmi -f ${REPOSITORY}/${NAME}:arm64.${VERSION}

help:
	@echo "make 格式化go代码 并编译生成二进制文件"
	@echo "make build "
	@echo "make run "
	@echo "make docker "